#!/usr/bin/env python
# -*- coding: utf-8 -*-

import logging
import time
import warnings
from scapy.all import traceroute

class TestNetwork:
    def __init__(self,ip):
        self.ip = ip
    
    def checkip(self):
        #屏蔽scapy模块无用告警
        warnings.filterwarnings("ignore",category=DeprecationWarning)
        #屏蔽ipv6告警
        logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
        res,unans = traceroute(self.ip,timeout=1,retry=-2)
        res.graph(target="> test.svg")
        time.sleep(1)

if __name__ == '__main__':
    ip = input('请输入ip地址:')
    test = TestNetwork(ip)
    test.checkip()